<?php

    if (! defined('SIMPLE_TEST')) {
        define('SIMPLE_TEST', '../simpletest/');
    }
    require_once(SIMPLE_TEST . 'autorun.php');

    require_once '../Sql/DBSeguridadDAO.php';
    require_once '../Sql/conexion.php';
    require_once '../Sql/claseDB.php';
    require_once '../Exception/CustomException.php';


class DBUsuarioDAOTest extends UnitTestCase {

    function DBUsuarioDAOTest() {
            $this->UnitTestCase();
        }


   function testlogin() {
       $DBConn = null;
       $conexion = new conexion();
       $DBConn = $conexion->setConnect();
       $DBConn->consulta( "INSERT INTO Usuario
                          VALUES (-1,123,'Daniel',
                          'Cardoza','ccs',3832646,
                          'sondy99@gmail.com','123','ADMIN',1)" );

       $miDBSeguridadDAOTest = new DBSeguridadDAO();
       $this->assertTrue( $miDBSeguridadDAOTest->login(123, 123) );
       $this->assertEqual( -1 , $_SESSION['USR_ID'] );
       $this->assertEqual( "Daniel" , $_SESSION['USR_NOMBRE'] );
       $this->assertEqual( "Cardoza" , $_SESSION['USR_APELLIDO'] );
       $this->assertEqual( "ADMIN" , $_SESSION['USR_PRIVILEGIO'] );
       $this->assertFalse( $miDBSeguridadDAOTest->login(111, 123) );
       $this->assertFalse( $miDBSeguridadDAOTest->login(123, 111) );
       $DBConn->consulta( "DELETE FROM usuario
                          WHERE USR_ID = -1" );
       $this->assertFalse( $miDBSeguridadDAOTest->login(123, 123) );

    }

}

?>
